package com.senlingspace.web.controller.headquarters;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.senlingspace.common.annotation.Log;
import com.senlingspace.common.core.controller.BaseController;
import com.senlingspace.common.core.domain.AjaxResult;
import com.senlingspace.common.enums.BusinessType;
import com.senlingspace.system.domain.SlkjInvestor;
import com.senlingspace.system.service.ISlkjInvestorService;
import com.senlingspace.common.utils.poi.ExcelUtil;
import com.senlingspace.common.core.page.TableDataInfo;

/**
 * 投资方Controller
 * 
 * @author SenlingSpace
 * @date 2024-06-26
 */
@RestController
@RequestMapping("/system/investor")
public class SlkjInvestorController extends BaseController
{
    @Autowired
    private ISlkjInvestorService slkjInvestorService;

    /**
     * 查询投资方列表
     */
    @PreAuthorize("@ss.hasPermi('system:investor:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlkjInvestor slkjInvestor) {
        List<SlkjInvestor> list = slkjInvestorService.selectSlkjInvestorList(slkjInvestor);
        return getDataTable(list);
    }

    /**
     * 导出投资方列表
     */
    @PreAuthorize("@ss.hasPermi('system:investor:export')")
    @Log(title = "投资方", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlkjInvestor slkjInvestor)
    {
        List<SlkjInvestor> list = slkjInvestorService.selectSlkjInvestorList(slkjInvestor);
        ExcelUtil<SlkjInvestor> util = new ExcelUtil<SlkjInvestor>(SlkjInvestor.class);
        util.exportExcel(response, list, "投资方数据");
    }

    /**
     * 获取投资方详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:investor:query')")
    @GetMapping(value = "/{investorId}")
    public AjaxResult getInfo(@PathVariable("investorId") Long investorId)
    {
        return success(slkjInvestorService.selectSlkjInvestorByInvestorId(investorId));
    }

    /**
     * 新增投资方
     */
    @PreAuthorize("@ss.hasPermi('system:investor:add')")
    @Log(title = "投资方", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlkjInvestor slkjInvestor)
    {
        return toAjax(slkjInvestorService.insertSlkjInvestor(slkjInvestor));
    }

    /**
     * 修改投资方
     */
    @PreAuthorize("@ss.hasPermi('system:investor:edit')")
    @Log(title = "投资方", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlkjInvestor slkjInvestor)
    {
        return toAjax(slkjInvestorService.updateSlkjInvestor(slkjInvestor));
    }

    /**
     * 删除投资方
     */
    @PreAuthorize("@ss.hasPermi('system:investor:remove')")
    @Log(title = "投资方", businessType = BusinessType.DELETE)
	@DeleteMapping("/{investorIds}")
    public AjaxResult remove(@PathVariable Long[] investorIds)
    {
        return toAjax(slkjInvestorService.deleteSlkjInvestorByInvestorIds(investorIds));
    }
}
